<%@page import="java.util.*"%>
<%@page import="Test.*"%>
<%@page import="Servlet.Alert"%>
<%@page import="DBModule.*"%>
<%@page import="Interact.Interface"%>
<%@page import="User.User" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="css/default.css" type="text/css" />
<title>输入题目描述</title>
</head>
<body>
<form method="post" action="TestServlet?method=setquestionbody">
<%
	int type;
	try{
		type = Integer.parseInt(request.getParameter("questionType"));
	}
	catch (Exception e){
		response.sendRedirect("index.jsp");
		return;
	}
	
	try{
		User teacher = (User)session.getAttribute("user");
		if (teacher == null || teacher.getType() != User.TEACHER){
			Alert.setAlertMsg(request, "用户未登陆，或不是教师");
			response.sendRedirect("alert.jsp");
			return;
		}
		Question q = Question.factory.createObject(type);
		QuestionBody body = q.getBody();
		body.setId(new Random().nextInt(100000));
		session.setAttribute("body", body);
		Interface inf = new Interface(out);
		inf.print(body);
%>
	<br/>该题目分值为&nbsp;<input name="grade">
	<br/>该题目所属科目为&nbsp;<select name="course">
<%
		Collection<Course> courses = TestPaperManager.getAllCourses(teacher);
		Iterator<Course> iter = courses.iterator();
		while (iter.hasNext()){
			Course course = iter.next();
%>
		<option value="<%=course.getId() %>"><%=course.getName()%></option>
<%
		}
%>
	</select>
<%
	}
	catch (Exception e){
		Alert.setAlertMsg(request, e.getMessage());
		response.sendRedirect("alert.jsp");
		return;
	}
%>
	<input type="submit" value="提交">
</form>
</body>
</html>











